package com.lvmama.java.rhino.spark.core.zookeeper;

/**
 * 注册Zookeeper事件监听
 * @author wxliyong
 */
public class WatchExecutor extends Thread {
	private String znode;
	private ZNodeListener listener;

	public WatchExecutor(String znode, ZNodeListener listener) {
		this.znode = znode;
		this.listener = listener;
	}

	public void run() {
		ZNodeMonitor dm = new ZNodeMonitor(znode, listener);
		dm.start();
		synchronized (this) {
			while(!dm.isOver()) {
				try {
					wait();
				} catch (InterruptedException e) {
				}
			}
		}
	}
}